<template>
<div class="factory-calendar part">
  <q-tabs
    v-model="tab"
    shrink stretch dense
    inline-label
    align="left"
    active-color="primary"
    indicator-color="primary"
  >
    <q-tab
      v-stat="{id:CommonConfig.statData.factoryCalendar.classMana.id,name:CommonConfig.statData.factoryCalendar.classMana.name}"
      v-has="{id: Enums.SYS_PERMISSION.SHIFT_TAB.value,
       type:Enums.SYS_PERMISSION.SHIFT_TAB.type}"
      name="gov" label="班制管理"
      icon="iconfont icontubiao-111"/>
    <q-tab
      v-stat="{id:CommonConfig.statData.factoryCalendar.teamLayout.id,name:CommonConfig.statData.factoryCalendar.teamLayout.name}"
      v-has="{id: Enums.SYS_PERMISSION.SCHEDULING_TAB.value,
      type:Enums.SYS_PERMISSION.SCHEDULING_TAB.type}"
      name="calendar" label="班组排班" icon="iconfont icontubiao-112"/>
  </q-tabs>
  <q-separator class="line"/>
  <q-tab-panels v-tabcur="{tab: [
  {id: Enums.SYS_PERMISSION.SHIFT_TAB.value, name: 'gov'},
   {id: Enums.SYS_PERMISSION.SCHEDULING_TAB.value, name: 'calendar'}
   ]}"
                v-model="tab" keep-alive animated class="height-full" style="margin: 0 -20px">
    <q-tab-panel
      v-has="{id: Enums.SYS_PERMISSION.SHIFT_TAB.value,
       type:Enums.SYS_PERMISSION.SHIFT_TAB.type}"
      name="gov" style="padding-left:0;padding-right: 0" class="full-height">
      <class-mana ref="classMana" class="full-height"></class-mana>
    </q-tab-panel>
    <q-tab-panel
      v-has="{id: Enums.SYS_PERMISSION.SCHEDULING_TAB.value,
      type:Enums.SYS_PERMISSION.SCHEDULING_TAB.type}"
      name="calendar" class="full-height">
      <team-layout ref="teamLayout" class="full-height"></team-layout>
    </q-tab-panel>
  </q-tab-panels>
</div>
</template>

<script>
import ClassMana from './class-mana'
import TeamLayout from './teamLayout'
import statMixin from '../../assets/js/stat-mixin'
export default {
  name: 'factory-calendar',
  mixins: [statMixin],
  data () {
    return {
      tab: 'gov' // gov|calendar
    }
  },
  created () {
    // 初始化埋点数据
    // this.addStat('dlp020401', '班制管理')
  },
  methods: {
    /**
     * 全局刷新数据
     * author: xueli
     */
    refreshInfo () {
      switch (this.tab) {
        case 'gov':
          this.$refs.classMana.plant = null
          this.$refs.classMana.getWorkshopList()
          this.$refs.classMana.getShiftsList()
          break
        case 'calendar':
          this.$refs.teamLayout.getInfo()
          break
        default:
          this.$refs.classMana.getWorkshopList()
          this.$refs.classMana.getShiftsList()
          break
      }
    }
  },
  components: {
    ClassMana,
    TeamLayout
  }
}
</script>

<style scoped lang="stylus">
.factory-calendar.part{
  padding 10px 20px 20px 20px;
  .height-full{
    height calc(100% - 36px)
  }
}
</style>
